import { FormSchema } from '/@/components/Table';
import { uploadApi } from '/@/api/sys/upload';
import { getAll as getAllClient } from '/@/api/business/client';
import { getDepts } from '/@/api/org/dept';
import { getAllList } from '/@/api/privilege/account';


/**
 * 表单字段定义
*/
export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'ID',
    component: 'Input',
    show: false,
  },
  {
    field: 'formNo',
    label: '普通字段',
    component: 'Input',
  },
  {
    field: 'formNo',
    label: '只读字段',
    component: 'Input',
    componentProps: {
      disabled: true,
    },
  },
  {
    field: 'x1',
    label: '数字字段',
    component: 'InputNumber',
  },
  {
    field: 'x2',
    label: '验证码倒计时',
    component: 'InputCountDown',
  },
  {
    field: 'x3',
    label: 'InputSearch',
    component: 'InputSearch',
  },


  {
    field: 'clientId',
    label: '下拉单选',
    helpMessage: 'ApiSelect组件，showSearch,optionFilterProp 两个属性支持搜索。',
    component: 'ApiSelect',
    componentProps: {
      api: getAllClient,
      //支持本地搜索
      showSearch: true,
      optionFilterProp: 'label',
      resultField: 'data',
      labelField: 'name',
      valueField: 'id',
    },
  },
  {
    field: 'clientId2',
    label: '下拉多选',
    component: 'ApiSelect',
    componentProps: {
      api: getAllClient,
      showSearch: true,
      mode: "multiple",
      resultField: 'data',
      labelField: 'name',
      valueField: 'id',
    },
  },
  {
    field: 'clientId',
    label: '<ApiSelect>',
    helpMessage: '页面中定义<ApiSelect>组件，showSearch,optionFilterProp 两个属性支持搜索。',
    component: 'Input',
    slot: 'localSearch',
  },

  {
    field: 'deptId',
    label: '选部门',
    component: 'Input',
    slot: 'selectDept',
  },
  {
    field: 'deptId',
    label: '下拉选部门',
    helpMessage: 'ApiTreeSelect 组件，showSearch, treeNodeFilterProp 两个属性支持搜索。',
    component: 'ApiTreeSelect',
    componentProps: {
      api: getDepts,
      showSearch: true,
      treeNodeFilterProp: 'label',
      mode: 'multiple',
      resultField: 'data',
      labelField: 'name',
      valueField: 'id',
    },
  },
  {
    field: 'deptNameList',
    label: '部门名称列表',
    component: 'Input',
    show: false,
  },

  {
    field: 'selectStaff',
    label: '选员工',
    component: 'Input',
    slot: 'selectStaff',
  },
  {
    field: 'staffId',
    label: '下拉选员工',
    component: 'ApiSelect',
    componentProps: {
      api: getAllList,
      showSearch: true,
      optionFilterProp: 'label',
      mode: 'multiple',
      resultField: 'data',
      labelField: 'realName',
      valueField: 'id',
    },
  },
  {
    field: 'selectStaffName',
    label: 'selectStaffName',
    component: 'Input',
    show: false,
  },

  {
    field: 'fileList',
    label: '文件上传',
    component: 'Upload',
    colProps: { span: 24 },
    componentProps: {
      api: uploadApi,
    },
  },
  {
    field: 'detailList',
    label: '可编辑表格',
    component: 'Input',
    slot: 'detailList',
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    colProps: { span: 24 },
  },
];
